<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	response.setHeader("cache-control","public");
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<!-- 创建考试第一步 -->
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="renderer" content="webkit">
	<title>考务管理</title>
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/font/font-awesome.min.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/common.css" />
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/core.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/exam-org-deta.css" />
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/exam-org.css" />
	<!--bootstrap基础引用 start-->
	<script type="text/javascript" src="<%=path%>/static/jstreeview/bootstrap/jquery-3.1.1.min.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/bootstrap.min.js"></script>
	<!--bootstrap基础引用 end-->
	<!--bootstrap-dialog start-->
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.css">
	<script type="text/javascript" src="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.js"></script>
	<!--bootstrap-dialog end-->
	<script src="<%=path%>/static/js/respond.js"></script>
	<!--[if !IE]> -->
	<script type="text/javascript">
		window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
	</script>
	<!-- <![endif]-->

	<script type="text/javascript">
		window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-1.9.1.min.js'>" + "<" + "/script>");
	</script>

</head>

<body>

<jsp:include page="../head.jsp" flush="true"/>
<div class="main-container albox-pad-top padingtop0">
	<div class="panel container body-box">
		<div class="panel-heading col-lg-12 col-md-12  top-brgclr" style="height: 70px; background: #4c4ca6;">
			<c:choose>
				<c:when test="${not empty (unit)}">
					<p class=" col-lg-10 col-md-10 col-sm-10 color-fff">编辑单位</p>
				</c:when>
				<c:otherwise>
					<p class=" col-lg-10 col-md-10 col-sm-10 color-fff">新增单位</p>
				</c:otherwise>
			</c:choose>
			<a class="color-fff floatrit aahover fontweight400" href="javascript:history.back(-1)"><span class="glyphicon glyphicon-arrow-left "></span> 返回</a>
		</div>
		<div class="panel-body minheight" style="min-height: 0px;">
			<div class=" borderbottom">
			</div>
			<!--
                作者：306794978@qq.com
                时间：2016-06-22
                描述：第一步开始
            -->
			<div id="stypediv1" class=" form-box col-lg-12 col-md-12 col-sm-12 stype1displaynone2" style="min-height: 260px; ">
				<form class="form-inline col-lg-12 col-md-12 col-sm-12">
					<div class="form-group col-lg-12 col-md-12 col-sm-12 padding-0">
						<div class="input-group-box dept-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">单位名称</div>
								<c:choose>
									<c:when test="${not empty (unit) }">
										<input type="text" id="unitname" class="form-control" value="${unit.name }" id="text1"  />
									</c:when>
									<c:otherwise>
										<input type="text" id="unitname" class="form-control" maxlength="30"  placeholder="请输入单位名称" id="text1"  />
									</c:otherwise>
								</c:choose>

							</div>
						</div>
						<div class="input-group-box dept-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">单位代码</div>
								<c:choose>
									<c:when test="${not empty (unit) }">
										<input type="text" class="form-control" value="${unit.code}" id="unitcode" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" id="unitcode" placeholder="请输入单位代码" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>
                    </div>
                    <div class="input-group-box dept-lg-6 col-md-6 col-sm-6">
                        <div class="input-group col-lg-12 col-md-12 col-sm-12">
                            <div class="input-group-addon width150">单位编号</div>
                            <c:choose>
                                <c:when test="${not empty (unit) }">
                                    <input type="text" class="form-control" value="${unit.identifier}" id="unitnum" maxlength="30" />
                                </c:when>
                                <c:otherwise>
                                    <input type="text" class="form-control" id="unitnum" placeholder="请输入单位编号" maxlength="30" />
                                </c:otherwise>
                            </c:choose>
                        </div>
                    </div>
				</form>
			</div>
		</div>
	</div>
	<div class="stypebox">
		<div  class=" form-submit floatleft" >
			<div id="stypeback" onclick="javascript:history.back(-1)" class="btn btn-default  margintopbom ">
				<span class="">取消</span>
			</div>
		</div>
		<div class="form-submit floatrit">
			<div  id="validation" class="btn btn-info margintopbom">
				<span style="color: #FFFFFF">确定 </span> 
			</div>
		</div>
	</div>


	<!--body end-->
	<script type="text/javascript" src="<%=path%>/static/js/jquery-ui.min.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/jquery.selectlist.js" ></script>
	<script type="text/javascript" src="<%=path%>/static/js/global.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/tooltip.js"></script>
</div>
</div>
</body>
<script type="text/javascript">
	$(function(){
		// $('#topMain').children().eq(1).addClass('active'); // 追加样式;

		//单位管理
		if (${role eq 'master'}) {
			$('#topMain').children().eq(0).addClass('active'); // 追加样式;
			$('#topMain').children().eq(0).children().attr('href', '#');
		} else if (${role eq 'trainee'}) {
			$('#topMain').children().eq(0).addClass('active'); // 追加样式;
			$('#topMain').children().eq(0).children().attr('href', '#');
		} else {
			$('#topMain').children().eq(1).addClass('active'); // 追加样式;
			// $('#topMain').children().eq(1).children().attr('href', '#');
		}

	})
	$(document).ready(function(){
		$("#proDiv").css("display","none");
		$("#rankDiv").css("display","none");
	})
	var titleType = 0;
	//确定点击事件
	$("#validation").click(function(){
		var name = $("#unitname").val();
		var code = $("#unitcode").val();
		var identifier = $("#unitnum").val();

			$.ajax({
				url : '<%=basePath%>dept/save',
				data: {
					id:'${unit.id}',
					name:name,
					code:code,
					identifier:identifier
				},
				dataType : "json",
				success : function(data) {
					if (data[0].status==1) {
						BootstrapDialog.confirm({
							title : '提示',
							message : '保存成功',
							size : BootstrapDialog.SIZE_SMALL,
							type : BootstrapDialog.TYPE_DEFAULT,
							closable : true,
							btnCancelLabel : '取消',
							btnOKLabel : '确定',
							callback:function(result){
								window.location.href="<%=basePath%>dept/unitindex";
							}
						});
					} else {
						BootstrapDialog.confirm({
							title : '提示',
							message : data[0].Msg,
							size : BootstrapDialog.SIZE_SMALL,
							type : BootstrapDialog.TYPE_DEFAULT,
							closable : true,
							btnCancelLabel : '取消',
							btnOKLabel : '确定',
							callback:function(result){
							}
						});
					}

				}
			});


	});
	function changeRole(){
		var role  = $("#role").val();
		role = role.trim();
		if(role=="3"){
			$("#proDiv").css("display","block");
			$("#rankDiv").css("display","block");
		}else{
			$("#proDiv").css("display","none");
			$("#rankDiv").css("display","none");
		}
	}
</script>

</html>